Skip to content

fix(reader): reduce long-strip scroll jank in continuous scroll - #112

Merged
zyk1172 merged 3 commits into
mainfrom
fix/strip-scroll-performance
Nov 29, 2026
Merged

zyk1172 merged 3 commits into
mainfrom
fix/strip-scroll-performance

Conversation

@zyk1172

@zyk1172 zyk1172 commented Nov 28, 2026 •

Copy link
Copy Markdown
Owner

条漫连续滚动

快速滑过分页边界时,阅读器需要用最新页框确定当前页,给可见页保留解码资源,并在反向滑动时复用邻页图片。

  • 连续滚动空闲时可同时预载两页。已有前台加载时限制新启动的邻页任务,队列出队前检查更高分辨率的缓存和在途解码。每个预载窗口只为每页解析一次文件标识,减少在主线程反复查询 CBZ 和 PDF 属性。
  • 占位布局和预载预算使用按 EXIF 方向校正后的原始尺寸。打开阅读进度条并生成小缩略图时,后续整页解码仍按原图估算占用。
  • 合并可见页计算时保留最新布局。回滑到超长第一页的中下部也能正确更新页码,快速甩回顶部后保留用户的滚动位置。
  • 常规滚动仅使用基础图块,捏合放大时启用 2×、4× 层级,缩回后关闭。保留分块裁绘和前后各三页的视图持图范围。四组 Mac 位图绘制对照中,整图裁切未表现出一致优势。报告顶部列出了逐项复核依据。

验证

  • 本地 Xcode 27 的 arm64 模拟器目标通过 build-for-testing。项目登记的 SimSlim profile 在分支中缺失,本地未启动模拟器。
  • 回归用例覆盖缩放时切换图块层级、超长首页回滑,以及带旋转信息的 JPEG 经过两次降采样后仍保留原始几何。
  • 长条 UI 用例执行 25 次向前快滑、25 次反向快滑,并断言实际跨页和回到起始页。远端运行详情见 iOS CI。
  • 真机掉帧和内存峰值仍待 iPhone Instruments 实测。

最终实测

5dac48a 的远端 Release 构建通过。单元测试 701 项通过、10 项跳过,Manga Vision 回归 6 项通过,UI 测试 9 项通过、1 项跳过。三项新增单测与长条往返 UI 用例均通过。

iPhone 17 模拟器、iOS 26.5 的长条往返用例记录了以下进程物理内存峰值(按十进制 MB 换算)。

版本 峰值
main 基线 196.8 MB
原 PR 124.0 MB
中间修订,常驻放大层级 197.0 MB
最终提交,按需启用放大层级 124.1 MB

最终提交的 25 次向前快滑确实跨页,25 次反向快滑后回到了起始页。各版本数字均为一次 CI 测量,早期用例缺少页码断言。最终 xcresult 只提供了内存指标,尚无 iPhone 掉帧率数据。

ZHENG YUNKAI added 3 commits November 29, 2026 03:50
Fixes several compounding bottlenecks on the webtoon/long-strip reading hot path:

- ReaderStripTileLayer: drop levelsOfDetailBias (2 -> 0). Long strips render at fitWidth and are never zoomed, so the magnification LOD tiers only force the highest-LOD tile on first display and keep extra magnified bitmaps resident for no benefit.
- ReaderStripTileLayer.draw: draw the full image once and let Core Graphics clip to the tile's dirty region instead of allocating a fresh bitmap via CGImage.cropping(to:) on every draw callback.
- ReaderImageCache: continuous scroll now keeps a neighbour decode running even while a foreground page is decoding (new allowConcurrentDuringForegroundLoad flag) and preloads with maximumConcurrent 2, so the pipeline no longer stalls during a fast scroll.
- ContinuousScrollReader: widen retainsDecodedImage from <= 3 to <= 5 so scrolling back up does not re-decode recently rendered pages.

Adds docs/reader-strip-scroll-performance-review-2026-11-29.md with the full audit and remaining lower-priority follow-ups.
@zyk1172
zyk1172 merged commit aa0f5c3 into main Nov 29, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant